home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Conversion / Convert_PICT / Convert PICT.app / UncommentedPSCode / Common < prev    next >
Text File  |  1994-05-24  |  5KB  |  240 lines

  1. /COPYING_INFO
  2. (
  3.     Created by Convert PICT a PICT to eps converter.
  4.     Copyright (C) 1993 David John Burrowes
  5.     The following PS routines are distributed under terms of GNU General Public License. 
  6.     See any copy of the GPL for more info. E.g. in COPYING in Convert PICT's online help.
  7. )
  8. def
  9. %BEGIN Common
  10. /penWidth 1 def
  11. /penHeight 1 def
  12. /lastTop 0 def
  13. /lastLeft 0 def
  14. /lastBottom 0 def
  15. /lastRight 0 def
  16. /foregroundColor [0 0 0] def
  17. /backgroundColor [1 1 1] def
  18. /backPattern 20 dict def
  19. backPattern begin
  20.     /QDPatType 0 def
  21.     /QDPatData <FFFFFFFFFFFFFFFF>  def    % white
  22.     /QDPatGrey    1 def
  23. end
  24. /penPattern 20 dict def
  25. penPattern begin
  26.     /QDPatType 0 def
  27.     /QDPatData <0000000000000000>  def
  28.     /QDPatGrey    0 def
  29. end
  30. /fillPattern 20 dict def
  31. fillPattern begin
  32.     /QDPatType 0 def
  33.     /QDPatData <0000000000000000>  def    % black
  34.     /QDPatGrey    1 def
  35. end
  36. /patternMode    /patCopy    def
  37. /PSlevel
  38.     systemdict /languagelevel known
  39.         {languagelevel}
  40.         {1}
  41.     ifelse
  42. def
  43. /usePattern
  44. {
  45.     /QDPatternDict exch def
  46.     /patternType QDPatternDict /QDPatType get def
  47.     patternType 2 eq
  48.     { QDPatternDict /QDColorValue  get  useColor }
  49.     {
  50.         PSlevel 1 eq
  51.         {
  52.             /patGrey  QDPatternDict /QDPatGrey get  def
  53.             /invGrey 1 patGrey sub def
  54.             0 1 2
  55.             {
  56.                 /index exch def
  57.                 foregroundColor index get invGrey mul
  58.                     backgroundColor index get patGrey mul add
  59.             }
  60.             for
  61.             setrgbcolor
  62.         }
  63.         {
  64.             patternType 0 eq
  65.             {
  66.                 /PSPatDict 15 dict def
  67.                 PSPatDict begin
  68.                     /PaintType    1    def
  69.                     /PatternType    1    def
  70.                     /TilingType    1    def
  71.                     /BBox        [0 0 8 8]    def
  72.                     /XStep        8    def
  73.                     /YStep        8    def
  74.                     /myData    QDPatternDict /QDPatData get def
  75.                     /PaintProc    {
  76.                                 begin
  77.                                     patternMode /patBic eq
  78.                                     patternMode /notPatCopy eq
  79.                                     or
  80.                                         { 0 1 2 { backgroundColor exch get } for }
  81.                                         { 0 1 2 { foregroundColor exch get } for }
  82.                                     ifelse
  83.                                     setrgbcolor
  84.                                     8 8 false
  85.                                     [1 0 0  1 0 0] 
  86.                                     myData
  87.                                     imagemask
  88.                                     patternMode /notPatOr eq
  89.                                     patternMode /notPatCopy eq
  90.                                     or
  91.                                         { 0 1 2 { foregroundColor exch get } for }
  92.                                         { 0 1 2 { backgroundColor exch get } for }
  93.                                     ifelse
  94.                                     setrgbcolor
  95.                                     8 8 true
  96.                                     [1 0 0  1 0 0] 
  97.                                     myData
  98.                                     imagemask
  99.                                 end
  100.                                 } def 
  101.                 end
  102.                 PSPatDict matrix makepattern setpattern
  103.             }
  104.             {
  105.                 /PSPatDict 20 dict def
  106.                 PSPatDict begin
  107.                     /PaintType    1    def
  108.                     /PatternType    1    def
  109.                     /TilingType    1    def
  110.                     /BBox        [0 0 QDPatternDict  /QDDestWidth  get
  111.                                     QDPatternDict  /QDDestHeight get] def
  112.                     /XStep        QDPatternDict  /QDDestWidth  get def
  113.                     /YStep        QDPatternDict  /QDDestHeight get def
  114.                     /ImageType    1    def
  115.                     /Width        QDPatternDict  /Width get def
  116.                     /Height        QDPatternDict  /Height get def
  117.                     /BitsPerComponent
  118.                                 QDPatternDict  /BitsPerComponent get  def
  119.                     /Decode            [ 0 2 BitsPerComponent exp 1 sub ] def
  120.                     /ImageMatrix    [1 0 0  1 0  0]  def
  121.                     /DataSource     QDPatternDict  /QDPatBitmap get def
  122.                     /PaintProc    {
  123.                                     /ourDict exch def 
  124.                                     [/Indexed /DeviceRGB
  125.                                         QDPatternDict  /QDNumColors get
  126.                                         QDPatternDict  /QDColorTable get]
  127.                                     setcolorspace
  128.                                     ourDict  image
  129.                                 } def 
  130.                 end
  131.                 PSPatDict matrix makepattern setpattern
  132.             }
  133.             ifelse
  134.         }
  135.         ifelse
  136.     }
  137.     ifelse
  138. }
  139. def
  140. /useColor
  141. {
  142.     /colorArray exch def
  143.     colorArray 0 get
  144.     colorArray 1 get
  145.     colorArray 2 get
  146.     setrgbcolor
  147. }
  148. def
  149. /setupForArcPath
  150. {
  151.     /ovalLeft exch def
  152.     /ovalBottom exch  def
  153.     /ovalHeight exch  def
  154.     /ovalWidth exch  def
  155.     
  156.     ovalHeight 0 le
  157.     ovalWidth 0 le
  158.     or
  159.     { 0 0 0 }    % if height or with <= 0, return center 0,0 radius 0
  160.     {
  161.         ovalWidth ovalHeight gt
  162.         {
  163.             1 ovalHeight ovalWidth div scale
  164.             ovalLeft ovalWidth 2 div add    % X coordinate center
  165.             ovalBottom ovalHeight 2 div  sub ovalWidth ovalHeight div mul
  166.             ovalWidth 2 div                    % radius
  167.         }
  168.         {
  169.             ovalWidth ovalHeight div 1 scale
  170.             ovalLeft ovalWidth 2 div  add   ovalHeight ovalWidth div   mul
  171.             ovalBottom ovalHeight 2 div sub    % Y coord center
  172.             ovalHeight 2 div                % radius
  173.         }
  174.         ifelse
  175.     }
  176.     ifelse
  177. }
  178. def
  179. /regionBounds
  180. {
  181.     /right    exch def
  182.     /bottom    exch def
  183.     /left        exch def
  184.     /top        exch def
  185.     newpath
  186.         left top moveto
  187.         right top lineto
  188.         right bottom lineto
  189.         left bottom lineto
  190.     closepath
  191. }
  192. def
  193. /regionPath
  194. {
  195.     /numShapes exch def
  196.     newpath
  197.     numShapes
  198.     {
  199.         /numPoints exch def
  200.         /y exch def
  201.         /x exch def
  202.         x y moveto
  203.         numPoints 1 sub
  204.         {
  205.             /y exch def
  206.             /x exch def
  207.             x y lineto
  208.         }
  209.         repeat
  210.         closepath
  211.     }
  212.     repeat
  213. }
  214. def
  215. /startPict
  216.     {pop}
  217. def
  218. /QDclip
  219. {
  220.     initclip
  221.     regionBounds
  222.     clip
  223.     /numShapes exch def
  224.     numShapes  0 gt
  225.     {
  226.         numShapes
  227.         regionPath
  228.         clip
  229.     }
  230.     if
  231. }
  232. def
  233. /endPict
  234.     {}
  235. def
  236. /headerOp
  237.     {pop}
  238. def
  239. %END Common
  240.